#!/usr/bin/env bash

# Theme: Haskell
# --------------
# basename/ λ: ▏
#
# Within Git repository:
# basename/branch λ: ▏
#
# Within SSH session:
# hostname:basename/branch λ: ▏
#
# Within virtualenv:
# venv/basename/branch λ: ▏

function ps1_context {
	local virtualenv
	if [ ! -z "$VIRTUAL_ENV" ]; then
		virtualenv="$(basename "$VIRTUAL_ENV")"
		echo -n "${virtualenv:+${virtualenv}/}"
	fi
}

LS_COLORS="$(vivid generate snazzy)"
export LS_COLORS

if [ -z "$(LC_ALL=C type -t __git_ps1)" ]; then
	__git_ps1() {
		echo ''
	}
fi

# Load directory and file colors for GNU ls
# eval "$(dircolors -b "$XDG_CONFIG_HOME/bash/dircolors")"

if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
	# Local connections
	PS1='\[\e[31m\]$(ps1_context)\[\e[34m\]${PWD##*/}/\[\e[90m\]$(__git_ps1 "%s") \[\e[32m\]λ\[\e[0m\]: '
else
	# Remote connections
	PS1='\[\e[31m\]$(ps1_context)\[\e[33m\]\h\[\e[90m\]:\[\e[34m\]${PWD##*/}/\[\e[90m\]$(__git_ps1 "%s") \[\e[32m\]λ\[\e[0m\]: '
fi
